<!--form元素开始-->
<div class="m-t ibox-content layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input type="text" name="tel" required  lay-verify="required" placeholder="业主手机号码" autocomplete="off" class="layui-input" maxlength="15">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" required  lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验证码</label>
        <div class="layui-input-block">
            <input type="text" name="code" required  lay-verify="required" placeholder="点击图片刷新" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <img src="{:captcha_src()}" onclick="javascript:this.src='{:captcha_src()}?tm='+Math.random()"  style="width: 200px; height: 50px;margin-top: 10px;" />
        </div>
    </div>
    <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element-login">登录</button>
</div>
<!--form元素结束-->
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(component-form-element-login)', function (data) {
            var index = layer.load();
            //$('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('index/user/login')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.data == 1) {
                        layer.close(index);
                        layer.msg(res.message);
                        setTimeout(window.location.href="{:url('index/index/index')}",8000);
                    } else if (res.data == 0) {
                        layer.close(index);
                        layer.open({
                            title: '注册失败'
                            ,content: res.message
                        });
                    } else {
                        layer.close(index);
                        layer.open({
                            title: '注册失败'
                            ,content: '出现未知错误，如果问题一直出现，您可以联系管理员或站点留言'
                        });
                    }
                }
            })
        });
    });
</script>